package com.itheima.cases_demo.date_format;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Test {
    public static void main(String[] args) throws ParseException {
        // 日期时间格式化

        long now = System.currentTimeMillis();
        System.out.println(now);

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String formatString = simpleDateFormat.format(now);
        System.out.println("格式化后: " + formatString);

        // 字符串转日期
        String past = "2012-12-12 10:02:00";
        Date parseDate = simpleDateFormat.parse(past);
        System.out.println(parseDate);
    }
}
